package com.example.bzh.gamecat.ui.live;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.bzh.gamecat.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class LiveFragment extends Fragment {


    @BindView(R.id.iv_search_live)
    ImageView ivSearchLive;
    @BindView(R.id.iv_live_live)
    ImageView ivLiveLive;
    @BindView(R.id.iv_menu_live)
    ImageView ivMenuLive;
    @BindView(R.id.tab_live)
    TabLayout tabLive;
    @BindView(R.id.viewpager_live)
    ViewPager viewpagerLive;

    public LiveFragment() {

    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_live, container, false);
        ButterKnife.bind(this, view);
        initData();
        return view;
    }

    private void initData() {
        String[] title = getResources().getStringArray(R.array.live_title);
        LiveFragmentAdapter adapter = new LiveFragmentAdapter(getFragmentManager(), title);
        viewpagerLive.setAdapter(adapter);
        //设置当前页面显示为热门标签页
        viewpagerLive.setCurrentItem(1);
        tabLive.setupWithViewPager(viewpagerLive);
    }

    @OnClick({R.id.iv_search_live, R.id.iv_live_live, R.id.iv_menu_live})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_search_live:
                Toast.makeText(getActivity(), "搜索", Toast.LENGTH_SHORT).show();
                break;
            case R.id.iv_live_live:
                Toast.makeText(getActivity(), "直播", Toast.LENGTH_SHORT).show();
                break;
            case R.id.iv_menu_live:
                Toast.makeText(getActivity(), "菜单", Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
